<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE>
<html>
<head>
<title>订单详情</title>
<link rel="stylesheet"
	href="<c:url value='/static/themes/lightbox2-master/css/lightbox.min.css'/>" />
</head>
<body>
	<div class="col-lg-12">
		<div id="message"></div>
		<div class="panel panel-default bk-bg-white">
			<div class="panel-heading bk-bg-white">
				<h2>订单详情</h2>
			</div>
			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form class="form-horizontal">
							<div class="row">
								<div class="form-group col-sm-5">
									<label class="col-sm-4 control-label">订单状态:</label>
									<div class="col-sm-8" style="padding-top: 10px;">
										<span style="color: #FFB253;"> <c:if
												test="${order.orderstatus == 1 }">
												已发布(待接单)
											</c:if> <c:if test="${order.orderstatus==2 }">
												已接单(待操作)
											</c:if> <c:if test="${order.orderstatus==3 }">
												已操作(待确认金额)
											</c:if> <c:if test="${order.orderstatus==4 }">
												已确认金额(待返款)
											</c:if> <c:if test="${order.orderstatus==5 }">
												已返款(待评价)
											</c:if> <c:if test="${order.orderstatus==6}">
												已评价(待审核)
											</c:if> <c:if test="${order.orderstatus==7}">
												已完成
											</c:if> <c:if test="${order.orderstatus==8}">
												已撤销
											</c:if>
										</span>
										<c:if test="${order.orderstatus<7}">
											<span class="label label-info" id="cancelOrder">撤销订单</span>
										</c:if>
									</div>
								</div>

							</div>
							<div class="row" style="padding-top: 20px">
								<h3>基础信息</h3>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">订单ID:</label>
									<div class="col-sm-7" style="padding-top: 10px;">${order.orderid }</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">任务ID:</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										<a href="${path }/task/detail/${order.taskid }">${order.taskid }</a>
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">平台:</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										<c:choose>
											<c:when test="${order.platformid==1 }">
												淘宝/天猫
											</c:when>
											<c:otherwise>
												京东
											</c:otherwise>
										</c:choose>
									</div>
								</div>
								<div class="row">
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">店铺:</label>
										<div class="col-sm-7" style="padding-top: 10px;">${order.storename }</div>
									</div>
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">任务类型:</label>
										<div class="col-sm-7" style="padding-top: 10px;">${order.tasktypename }</div>
									</div>
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">买手天天生财ID:</label>
										<div class="col-sm-7" style="padding-top: 10px;">${order.buyersuserid eq 'N'?'':order.buyersuserid  }</div>
									</div>
								</div>
								<div class="row">
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">申述状态:</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											<c:choose>
												<c:when test="${order.appealsstatus==0 }">
													等待处理
												</c:when>
												<c:when test="${order.appealsstatus==1 }">
													协商中
												</c:when>
												<c:when test="${order.appealsstatus==2 }">
													平台介入
												</c:when>
												<c:when test="${order.appealsstatus==3 }">
													已完结
												</c:when>
												<c:otherwise>
													无
												</c:otherwise>
											</c:choose>

										</div>
									</div>
								</div>
							</div>
							<div class="row" style="padding-top: 20px">
								<h3>实际金额信息</h3>
								<div class="form-group col-sm-4">
									<label class="col-sm-7 control-label">实际付给买手本金:</label>
									<div class="col-sm-5" style="padding-top: 10px;">${order.buyersclaimamount}</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-7 control-label">实际支付基础佣金:</label>
									<div class="col-sm-5" style="padding-top: 10px;">${order.basiscommission}</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-7 control-label">实际支付增值服务佣金:</label>
									<div class="col-sm-5" style="padding-top: 10px;">${order.valueaddedservicescommission }</div>
								</div>
							</div>
							<div class="row" style="padding-top: 20px">
								<h3>任务详情</h3>
							</div>
							<div class="table-responsive">
								<table class="table table-bordered">
									<thead>
										<tr>
											<th style="width: 70%;">任务商品信息</th>
											<th>成交价（元）</th>
											<th>每单拍下数量</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td>
												<div style="float: left;">
													<img width="100" height="100"
														src="${pic_root }${productin.id.mainMap }" />
												</div>
												<div style="float: left; width: 70%; padding-left: 15px;">
													<h4>${productin.id.productName }</h4>
													<p>
														<c:if test="${productin.id.productLink !='N' and !empty productin.id.productLink}">
															<a target="_blank" href="${productin.id.productLink }">商品链接</a>
														</c:if>
													</p>
												</div>
											</td>
											<td>￥${productin.id.price }</td>
											<td>${productin.id.perOrderContainingNum }</td>
										</tr>
									</tbody>
								</table>
							</div>

							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">价格区间:</label>
									<div class="col-sm-7" style="padding-top: 10px;">${order.pricerange }</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">商品所在地:</label>
									<div class="col-sm-7" style="padding-top: 10px;">${productin_area }</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">包邮:</label>
									<div class="col-sm-7" style="padding-top: 10px;">${basecommission.freeShippingMark==0?'包邮':'不包邮'}</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">排序方式:</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										<c:choose>
											<c:when test="${task.searchKeywordSortWay==1 }">
											按销量优先(推荐，排序较稳定)
										</c:when>
											<c:otherwise>
											按综合排序
										</c:otherwise>
										</c:choose>
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">收货付款人数:</label>
									<div class="col-sm-7" style="padding-top: 10px;">${task.peopleNumber }</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">直通车:</label>
									<div class="col-sm-7" style="padding-top: 10px;">${order.directtrain==1?'是':'否' }</div>
								</div>
							</div>


							<c:if test="${productin_not.size()>0 }">
								<div class="form-group col-sm-12 form-horizontal">
									<div class="row">
										<label class="col-sm-2 control-label">附属商品：</label>
									</div>
									<div class="row">
										<c:forEach items="${productin_not }" var="productin1">
											<div class="col-sm-6">
												<div class="table-responsive">
													<table class="table table-bordered">
														<thead>
															<tr>
																<th>任务商品</th>
																<th>成交价（元）</th>
																<th>每单拍下数量</th>
															</tr>
														</thead>
														<tbody>
															<tr>
																<td>
																	<div style="float: left;">
																		<img width="100" height="100"
																			src="${pic_root }${productin1.id.mainMap }" />
																	</div>
																</td>
																<td>￥${productin1.id.price }</td>
																<td>${productin1.id.perOrderContainingNum }</td>
															</tr>
															<tr>
																<td colspan="3">链接：<a target="_blank"
																	href="${productin1.id.productLink }">${productin1.id.productLink }</a>
																</td>
															</tr>
														</tbody>
													</table>
												</div>
											</div>
										</c:forEach>
									</div>
								</div>
							</c:if>


							<div class="row" style="padding-top: 20px">
								<h3>订单要求</h3>
							</div>
							<div class="form-group col-sm-12">
								<div class="col-sm-12">
									<c:forEach items="${taskAddedservics }" var="taskAddedservic">
										<c:if test="${taskAddedservic.level == 1 }">
											<h4>${taskAddedservic.name }</h4>
										</c:if>
										<c:if test="${taskAddedservic.level == 2 }">
											<h5 style="padding-left: 20px">${taskAddedservic.name }${taskAddedservic.value }</h5>
											<c:if test="${taskAddedservic.key=='22' }">
												<div class="col-sm-8" style="padding-left: 20px">
													<div class="table-responsive">
														<table class="table table-bordered">
															<thead>
																<tr>
																	<th width="16%">搜索关键词</th>
																	<c:if test="${taskAddedservic.attrs['key221']=='1' }">
																		<th width="16%">匹配浏览订单数</th>
																	</c:if>
																	<c:if test="${taskAddedservic.attrs['key222']=='1'  }">
																		<th width="16%">收藏加购物车数</th>
																	</c:if>
																	<c:if test="${taskAddedservic.attrs['key223']=='1'  }">
																		<th width="16%">商品评价</th>
																	</c:if>
																</tr>
															</thead>
															<tbody>
																<c:forEach items="${taskAddedservic.attrs['list'] }"
																	var="item">
																	<tr>
																		<td>${item.id.searchKeyword }</td>
																		<c:if test="${taskAddedservic.attrs['key221']=='1' }">
																			<td>${item.id.browseOrders  }</td>
																		</c:if>
																		<c:if test="${taskAddedservic.attrs['key222']=='1' }">
																			<td>${item.id.collectionAndShoppingCart }</td>
																		</c:if>
																		<c:if test="${taskAddedservic.attrs['key223']=='1' }">
																			<td>${item.id.productReviews }</td>
																		</c:if>
																	</tr>
																</c:forEach>

															</tbody>
														</table>
													</div>
												</div>
											</c:if> 
										</c:if>
										<c:if test="${taskAddedservic.level == 3 }">
											<h6 style="padding-left: 40px">${taskAddedservic.name }${taskAddedservic.value }</h6>
										</c:if>
										<c:if test="${taskAddedservic.level == 4 }">
											<h6 style="padding-left: 60px">${taskAddedservic.name }${taskAddedservic.value }</h6>
										</c:if>
									</c:forEach>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

		<div class="panel panel-default bk-bg-white">
			<div class="panel-heading bk-bg-white">
				<h2>操作进展</h2>
			</div>
			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<div class="table-responsive">
							<table class="table table-bordered">
								<thead>
									<tr>
										<th width="15%">任务步骤</th>
										<th width="15%">操作者</th>
										<th width="21%">操作时间</th>
										<th width="10%">是否完成</th>
										<th width="35%">内容</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${orderssteps }" var="ordersstep"
										varStatus="status">
										<tr>
											<td>${ordersstep.id.orderStepName }</td>
											<td><c:choose>
													<c:when test="${ordersstep.id.operatorRole == '0' }">
														平台
													</c:when>
													<c:when test="${ordersstep.id.operatorRole=='1' }">
														买手
													</c:when>
													<c:when test="${ordersstep.id.operatorRole=='2' }"> 
														商家
													</c:when>
												</c:choose></td>
											<td><fmt:formatDate
													value="${ordersstep.id.operatorTime}"
													pattern="yyyy-MM-dd HH:mm:ss" /></td>
											<td>${ordersstep.id.finishMark==48?'未完成':'已完成' }</td>
											<td><c:set var="ordersstepattachs"
													value="${ordersstepattachMap[ordersstep.id.orderStepId] }"></c:set>
												<c:forEach items="${ordersstepattachs }"
													var="ordersstepattach">
													<c:choose>
														<c:when test="${empty ordersstepattach.uploadPic }">
															[${ordersstepattach.attachPromptMsg}:${ordersstepattach.enterAmount }]
														</c:when>
														<c:when test="${ordersstepattach.uploadPic == 'N'}">
															[${ordersstepattach.attachPromptMsg}:${ordersstepattach.enterAmount }]
														</c:when>
														<c:otherwise>
															<a class="example-image-link"
																href="${pic_root }${ordersstepattach.uploadPic}"
																data-title="${ordersstepattach.attachPromptMsg}"
																data-lightbox="example-1"><img class="example-image"
																src="${pic_root }${ordersstepattach.uploadPic}"
																height="60" width="60" alt="" /></a>
														</c:otherwise>
													</c:choose>
												</c:forEach></td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="form-group " style="text-align: center;">
			<button type="button" id="back" class="btn btn-warning btn-sm"
				style="width: 150px">返回</button>
		</div>
	</div>
	<script type="text/javascript">
		$(function($) {
			//取消
			$('#back').click(function() {
				window.location.href = path + "/order/index";
			});
			$('.checkbox').click(function() {
				return false;
			});
			//取消订单
			$('#cancelOrder').click(function() {
				$.blockUI({ message: '加载中...' });
				$.ajax({
					type : "post",
					url : path + "/order/cancelOrder",
					cache : false,
					data : {
						orderId : '${order.orderid }',
						_t : new Date().getTime()
					},
					dataType : "json",
					success : function(data) {
						if (data.success) {
							showmessage(data.msg, function() {
								location.reload();
							});
						} else {
							$.unblockUI();
							showmessage(data.msg);
						}
					}
				});
			});
		});
		//显示消息
		function showmessage(msg, callback) {
			
			$('#message').ucMessage({
				msg : msg,
				callback : callback
			});
		}
	</script>
	<script type="text/javascript"
		src="<c:url value='/static/themes/lightbox2-master/js/lightbox.min.js'/>"></script>
</body>
</html>